<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>注册</title>
	</head>
	<script src="${pageContext.request.contextPath }/js/JQuery.js" type="text/javascript" charset="utf-8"></script>
	<script src="${pageContext.request.contextPath }/js/layui/layui.all.js" type="text/javascript" charset="utf-8"></script>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/layui/css/layui.css"/>
	<style type="text/css">
		body{background-image: url(${pageContext.request.contextPath }/img/loginbackground.jpg);font-family: "Microsoft Yahei";font-size: 16px;}
		.base{display: block;margin: auto;width: 350px;position: relative;top: 210px;background-color: white;border-radius: 10px;padding-bottom: 20px;opacity: 0.9;}
		.base >*{padding-left: 20px;padding-top: 5px;}
		.user >*{padding-top: 5px;}
		.servicer >*{padding-top: 5px;}
		.manager >*{padding-top: 5px;}
		.head{display: block;text-align: center;font-size: 28px;font-weight: bold;padding-top: 30px;}
		.servicer{display: none;}
		.manager{display: none;}
		.layui-btn-normal{margin: auto;display: block;width: 200px;margin-top: 20px;padding-bottom: 40px;}
	</style>
	<body>
		<div class="base">
			<span class="head">社区养老服务信息系统</span>
		<div class="select">
			<span>选择注册类型：</span>
			<select name="type" class="type">
				<option value ="1">用&nbsp;&nbsp;户&nbsp;&nbsp;注&nbsp;&nbsp;册</option>
				<option value ="2">服务人员注册</option>
				<option value ="3">管理员注册</option>
			</select>
		</div>
		<div class="user">
			<div>
				<span>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</span>
				<input type="text" placeholder="姓名" class='oldpeople_name'>
			</div>
			<div>
				<span>性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：</span>
				<input type="text" placeholder="性别" class='oldpeople_sex'>
			</div>
			<div>
				<span>身&nbsp;&nbsp;份&nbsp;&nbsp;&nbsp;证&nbsp;&nbsp;号：</span>
				<input type="text" placeholder="身份证号" class='oldpeople_idcard'>
			</div>
			<div>
				<span>住&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址：</span>
				<input type="text" placeholder="住址" class='oldpeople_address'>
			</div>
			<div>
				<span>电&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;话：</span>
				<input type="text" placeholder="电话" class='oldpeople_tel'>
			</div>
			<div>
				<span>爱&nbsp;&nbsp;&nbsp;好&nbsp;&nbsp;习&nbsp;&nbsp;惯：</span>
				<input type="text" placeholder="爱好习惯" class='oldpeople_description'>
			</div>
			<div>
				<span>家&nbsp;&nbsp;&nbsp;人&nbsp;&nbsp;电&nbsp;&nbsp;话：</span>
				<input type="text" placeholder="家庭电话" class='oldpeople_familytel'> 
			</div>
			<div>
				<span>登&nbsp;&nbsp;&nbsp;录&nbsp;&nbsp;密&nbsp;&nbsp;码：</span>
				<input type="password" placeholder="登录密码" class='upassword'>
			</div>
			<div>
				<span>确&nbsp;&nbsp;&nbsp;认&nbsp;&nbsp;密&nbsp;&nbsp;码：</span>
				<input type="password" placeholder="确认密码" class='upasswords'>
			</div>
			<button type="button" class="layui-btn layui-btn-normal userbtn">注册</button>
		</div>
		<div class="servicer">
			<div>
				<span>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</span>
				<input type="text" placeholder="姓名" class="servicer_name">
			</div>
			<div>
				<span>性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：</span>
				<input type="text" placeholder="男/女" class="servicer_sex">
			</div>
			<div>
				<span>身&nbsp;&nbsp;&nbsp;份&nbsp;&nbsp;证&nbsp;&nbsp;号：</span>
				<input type="text" placeholder="身份证号" class="servicer_idcard">
			</div>
			<div>
				<span>电&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;话：</span>
				<input type="text" placeholder="电话" class="servicer_tel">
			</div>
			<div>
				<span>登&nbsp;&nbsp;&nbsp;录&nbsp;&nbsp;密&nbsp;&nbsp;码：</span>
				<input type="password" placeholder="登录密码" class="spassword">
			</div>
			<div>
				<span>确&nbsp;&nbsp;&nbsp;认&nbsp;&nbsp;密&nbsp;&nbsp;码：</span>
				<input type="password" placeholder="确认密码" class="spasswords">
			</div>
			<button type="button" class="layui-btn layui-btn-normal servicerbtn">注册</button>
		</div>
		<div class="manager">
			<div>
				<span>登&nbsp;&nbsp;&nbsp;录&nbsp;&nbsp;密&nbsp;&nbsp;码：</span>
				<input type="password" placeholder="登录密码" class="mpassword">
			</div>
			<div>
				<span>确&nbsp;&nbsp;&nbsp;认&nbsp;&nbsp;密&nbsp;&nbsp;码：</span>
				<input type="password" placeholder="确认密码" class="mpasswords">
			</div>
			<button type="button" class="layui-btn layui-btn-normal managerbtn">注册</button>
		</div>
		</div>
	</body>
	<script type="text/javascript">
		window.onload=function(){
			var type='1';
			$(".type").on('input',function(){
				type=$(".type").val();
				console.log($(".type").val());
				if(type==1||type=='1'){
					$(".user").css("display","block");
					$(".servicer").css("display","none");
					$(".manager").css("display","none");
				}
				if(type==2||type=='2'){
					$(".user").css("display","none");
					$(".servicer").css("display","block");
					$(".manager").css("display","none");
				}
				if(type==3||type=='3'){
					$(".user").css("display","none");
					$(".servicer").css("display","none");
					$(".manager").css("display","block");
				}
			})
			$(".userbtn").click(function(){
				var oldpeople_name=$(".oldpeople_name").val();
				var oldpeople_sex=$(".oldpeople_sex").val();
				var oldpeople_idcard=$(".oldpeople_idcard").val();
				var oldpeople_address=$(".oldpeople_address").val();
				var oldpeople_tel=$(".oldpeople_tel").val();
				var oldpeople_description=$(".oldpeople_description").val();
				var oldpeople_familytel=$(".oldpeople_familytel").val();
				var account_password=$(".upassword").val();
				var account_passwords=$(".upasswords").val();
				var params={
						oldpeople_name:oldpeople_name,
						oldpeople_sex:oldpeople_sex,
						oldpeople_idcard:oldpeople_idcard,
						oldpeople_address:oldpeople_address,
						oldpeople_tel:oldpeople_tel,
						oldpeople_description:oldpeople_description,
						oldpeople_familytel:oldpeople_familytel,
						account_password:account_password
				}
				if(account_password==account_passwords){
					$.post("${pageContext.request.contextPath}/consumer/userloggin",params,function(data){
						if(data == "false"|| data==false){
							alert('注册失败请联系管理员');
						}else{
							alert('请记录账号：'+data);
						}
					});
				}else{
					alert("两次输入密码不一致请重新输入");
				}
				//console.log(params);
			})
			$(".servicerbtn").click(function(){
				var servicer_name= $(".servicer_name").val();
				var servicer_sex= $(".servicer_sex").val();
				var servicer_tel= $(".servicer_tel").val();
				var servicer_idcard= $(".servicer_idcard").val();
				var account_password= $(".spassword").val();
				var account_passwords= $(".spasswords").val();
				var params={
						servicer_name:servicer_name,
						servicer_sex:servicer_sex,
						servicer_tel:servicer_tel,
						servicer_idcard:servicer_idcard,
						account_password:account_password
				}
				console.log(params);
				if(account_password==account_passwords){
					$.post("${pageContext.request.contextPath}/consumer/servicerloggin",params,function(data){
						if(data == "false"|| data==false){
							alert('注册失败请联系管理员');
						}else{
							alert('请记录账号：'+data);
						}
					});
				}else{
					alert("两次输入密码不一致请重新输入");
				}
			})
			$(".managerbtn").click(function(){
				var account_password= $(".mpassword").val();
				var account_passwords= $(".mpasswords").val();
				var params={
						account_password:account_password
				}
				console.log(params);
				if(account_password==account_passwords){
					$.post("${pageContext.request.contextPath}/consumer/managerloggin",params,function(data){
						if(data == "false"|| data==false){
							alert('注册失败请联系管理员');
						}else{
							alert('请记录账号：'+data);
							window.location="${pageContext.request.contextPath }/jsp/login.jsp";
						}
					});
				}else{
					alert("两次输入密码不一致请重新输入");
				}
			})
		}
	</script>
</html>